#include <iostream>
#include <vector>
#include <algorithm>
using namespace std;
using ll=long long;
int n;
ll getCnt(int nLimits,vector<int>& vecArr){

	int left=0,right=0;
	ll nCnt=0;
	while(right<n){
		while(vecArr[right]-vecArr[left]>nLimits){
			++left;
		}
		nCnt+=right-left;
		++right;
	}
	return nCnt;
}
int main() {

	int l,r;
	cin>>n>>l>>r;
	vector<int> vecArr(n);
	for(int i=0;i<n;++i){
		cin>>vecArr[i];
	}
	sort(vecArr.begin(),vecArr.end());
	cout<<getCnt(r,vecArr)-getCnt(l-1,vecArr);
	
	return 0;
}
//1 2 3 5 6
